<template>
  <div class="sider-bar">
    <div class="sider-bar__action">
      <div class="sider-bar__action--item close"></div>
      <div class="sider-bar__action--item in"></div>
      <div class="sider-bar__action--item out"></div>
    </div>
    <div class="sider-bar__avatar">
      <el-avatar
        shape="square"
        :size="36"
        :src="userInfo.avatar || ''">
      </el-avatar>
    </div>
    <div class="sider-bar__menus">
      <router-link
        class="sider-bar__menus-item"
        v-for="(item, index) in menus"
        :key="index"
        :to="item.path">
        <img
          class="menus-item__icon"
          :src="require(`@/assets/icons/icon-${item.meta.icon}__${currentPage === item.name ? 'selected' : 'normal'}.png`)" />
      </router-link>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  data () {
    return {
    }
  },
  computed: {
    ...mapGetters([
      'userInfo'
    ]),
    currentPage () {
      return this.$route.name
    },
    menus () {
      return this.$router.options.routes[0].children
    }
  }
}
</script>

<style lang="less" scoped>
.sider-bar {
  position: relative;
  width: 60px;
  height: 100%;
  backdrop-filter: saturate(50%) blur(8px);
  background: rgba(226, 227, 227, .8);
  flex-shrink: 0;
  &__action {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    padding: 6px 0;
    &--item {
      position: relative;
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background-color: #D4D5D5;
      &.close {
        background-color: #FE5E57;
      }
      &.in {
        background-color: #FEBC2E;
      }
      &.out {
        background-color: #2AC940;
      }
    }
  }
  &__avatar {
    text-align: center;
    padding: 42px 0;
  }
  &__menus {
    &-item {
      display: flex;
      justify-content: center;
      margin-bottom: 20px;
      .menus-item__icon {
        width: 26px;
      }
    }
  }
}
</style>
